# 多进程实现

from do_something import *
import time
import multiprocessing

if __name__ == '__main__':
    start_time = time.time()
    size = 10000000
    procs = 10  # 创建进程数，也是要执行的次数
    jobs = []
    for i in range(procs):  # 创建进程
        out_list = []
        process = multiprocessing.Process(target=do_somethong, args=(size, out_list))
        jobs.append(process)
    for j in jobs:  # 一个一个的进程开始执行
        j.start()
    for j in jobs:  # 一个一个的进程关闭
        j.join()
    end_time = time.time()
    print('List processing completed!')
    print('multiprocessing time=', end_time - start_time)
